package my.dr.config;

import my.dr.interceptor.AdminInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //admin添加拦截器
        registry.addInterceptor(new AdminInterceptor())
                .addPathPatterns("/admin/**","/admin8/")//要拦截的路径
                .excludePathPatterns("/admin/login");//要放行的路径
        registry.addInterceptor(new AdminInterceptor())
                .addPathPatterns("/user/**","/user/")//要拦截的路径
                .excludePathPatterns("/user/login","/user/captcha","/user/qinfo","/user/qlogin","/user/register");//要放行的路径
    }
}
